import request from '@/utils/request'
import { param } from '../../utils'
import qs from 'qs'

// 查询合同信息列表
export function listContract(query) {
  return request({
    url: '/team/contract/list',
    method: 'get',
    params: query
  })
}

// 查询合同信息详细
export function getContract(id) {
  return request({
    url: '/team/contract/' + id,
    method: 'get'
  })
}

// 新增合同信息
export function addContract(data) {

  return request({
    url: '/team/contract',
    method: 'post',
    data: data
  })
}

// 修改合同信息
export function updateContract(data) {
  return request({
    url: '/team/contract',
    method: 'put',
    data: data
  })
}

// 删除合同信息
export function delContract(id) {
  return request({
    url: '/team/contract/' + id,
    method: 'delete'
  })
}

// 修改审核状态
export function changeAuditStatus(id, auditStatus) {
  let params = {id, auditStatus}
  let formParams = qs.stringify(params, {indices: false});

  return request({
    url: '/team/contract/audit',
    data: formParams,
    headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
    method: 'post'
  })
}

// 修改审核状态
export function changeAffixSealState(id) {
  let params = {id}
  let formParams = qs.stringify(params, {indices: false});

  return request({
    url: '/team/contract/affixSeal',
    data: formParams,
    headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
    method: 'post'
  })
}

// 下载文件
export function downloadFileByMinioUrl(id) {
  let params = {id}
  let formParams = qs.stringify(params, {indices: false});
  return request({
    url: '/team/contract/download',
    data: formParams,
    headers: {'content-type': 'application/x-www-form-urlencoded'}, // 表单参数
    method: 'post'
  })
}

/*export function downloadFileByMinioUrl(resource) {
  return request({
    url: '/common/download',
    method: 'get',
    params: resource
  })
}*/
